package com.facebook.app.client.view;

import com.facebook.app.client.ClusteringMethod;
import com.facebook.app.client.presenter.ClusterStrategyChoicePresenter;
import com.facebook.app.client.uiElements.ClusterStrategyChoiceTreeModel;
import com.google.gwt.core.client.GWT;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.cellview.client.CellBrowser;
import com.google.gwt.user.cellview.client.HasKeyboardSelectionPolicy.KeyboardSelectionPolicy;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Widget;
import com.google.gwt.view.client.SelectionModel;

public class ClusterStrategyChoiceView extends Composite implements ClusterStrategyChoicePresenter.Display {
	
	private static ClusterStrategyChoiceUiBinder uiBinder = GWT
	.create(ClusterStrategyChoiceUiBinder.class);
	
	interface ClusterStrategyChoiceUiBinder extends UiBinder<Widget, ClusterStrategyChoiceView> {
	}
	
	@UiField(provided = true)
	CellBrowser cellBrowser;
	
	@Override
	public Widget asWidget(SelectionModel<ClusteringMethod> selectionModel) {
		
		cellBrowser = new CellBrowser(new ClusterStrategyChoiceTreeModel(selectionModel), null);
		cellBrowser.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.ENABLED);
		cellBrowser.setAnimationEnabled(true);
		
		initWidget(uiBinder.createAndBindUi(this));
		return this;
	}
	
}
